Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

214
Views
How to automatically fix node build imports that are without ".js" at the end?

I have a personal project using node.js, express.js and typescript.

When I run command to build project, it does all right.

But when I try to run it, it crashes, because all imports are "wrong", have a look:

The file dist/index.js has this import:

import app from './core/app';
...

BUT, if I make this change to the import, it runs ok:

import app from './core/app.js';
...

I didn't want to create a script file to do this, how can I solve it?

I'm currently using node version 16.0.

Here is my folder structure

enter image description here

Here is my index.ts

import app from 'src/core/app';

/**
 * Initializing server
 */
app.listen(app.get('port'), () => console.log('Application running -> true'));

Here is my tsconfig.json

{
    "compilerOptions": {
        "lib": ["ES2021"],
        "target": "ES2021",
        "module": "ES2020",
        "moduleResolution": "node",
        "strict": true,
        "baseUrl": ".",
        "sourceMap": true,
        "outDir": "dist",
        "rootDir": "src",
        "skipLibCheck": true,
        "noImplicitAny": true,
        "esModuleInterop": true,
        "isolatedModules": true,
        "removeComments": true,
        "resolveJsonModule": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "useUnknownInCatchVariables": true,
        "allowSyntheticDefaultImports": true,
        "strictPropertyInitialization": false,
        "forceConsistentCasingInFileNames": true,
        "typeRoots": ["node_modules/@types", "src/@types"]
    },
    "include": ["src/**/*"],
    "exclude": ["node_modules", "dist"]
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!